<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        img{
            height: 320px;
            width: 640px;
        }
        .active{
            background-color: red;
        }
    </style>
</head>
<body>
    <img src="images/1.png" alt="">
    <div class="btn-List">
    <button class=>1</button>
    <button class=>2</button>
    <button class=>3</button>
    </div>
    <script src="jquery.js"></script>
    <script>
        let imgSrc=[
        "images/1.png","images/2.png","images/3.png"
        ]

        $("button").click(function(){
            let index=$(this).index();
            //切换图片
            $("img").attr("src",imgSrc[index])
            //切换背景色
            // $(this).addClass("active")
            //去掉背景色
            // $(this).removeClass("active")
            // $(this).toggleClass("active")

            $(this).addClass("active")
            //siblings获取其他同级元素
            $(this).siblings().removeClass("active")
        })
        
    </script>
</body>
</html>